#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int a[N];
vector<int> v[N];
int bit[N];
int lowbit(int x) { return x & -x; }
void update(int x, int d) {
  for (int i = x; i <= m; i += lowbit(i)) bit[i] += d;
}
int query(int x) {
  int res = 0;
  for (int i = x; i > 0; i -= lowbit(i)) res += bit[i];
  return res;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) cin >> a[i];
  rep(i, 1, n) a[i] %= m;
  rep(i, 1, n) v[a[i]].push_back(i);
  ll res = 0;
  rep(i, 1, n) {
    int x = query(m) - query(a[i] + 1);
    res += x;
    update(a[i] + 1, 1);
  }
  cout << res << endl;
  rep(k, 1, m - 1) {
    int x = m - k;
    for (int i : v[x]) {
      res += i * 2 - n - 1;
    }
    cout << res << endl;
  }
  return 0;
}